<template>
	<view class="container">
		<!-- left左侧列表 -->
		<view class="left">
			<!-- 循环遍历的 -->
			<view class="left_list" @click="leftChange(index)" :class="activeIndex==index?'activeList':''" v-for="(item,index) in list" :key="index">
				<label for="">{{item.catename}}</label>
			</view>
		</view>
		<!-- right右侧详细分类商品 -->
		<view class="right">
			<!-- 每一个小类 -->
			<view class="right_list" v-if="list.length>0">
				<!-- 商品 -->
				<view class="bottom" v-for="(item,index) in list[activeIndex].children" :key="item.id">
					
					<view class="bottom_list">
						<!-- 每个最多显示6个 -->
						<view >
							<image :src="baseUrl+item.img" alt="">
						</view>
						<view class="title">
							<span>{{item.catename}}</span>
						</view>
					</view>
					
					
				</view>
				
			</view>
		</view>
		
		
		
	</view>
</template>

<script>
	import {baseUrl} from "../../utils/config.js"
	export default{
		data(){
			return{
				list:[],
				activeIndex:0,
				baseUrl:baseUrl
			}
		},
		async onLoad(){
			var result = await this.http("/api/getcates").catch(err=>{
				console.log(err)
			})
			// console.log(result);
			this.list = result.data.list
			// console.log(this.list);
		},
		methods:{
			leftChange(index){
				this.activeIndex = index
			}
		}
	}
</script>

<style>
	/* 导入外部的样式文件 */
	@import url("../../common/css/classify.css");
	
	/* 点击左侧导航，显示动态样式 */
	.activeList{
		border-left: 6rpx solid #f26b11;
		color: #f26b11;
	}
</style>
